unit mcu_poplist;

interface

type
 rpopitem = record
  subject: string;
  date: string;
  from: string;
  id: string;
  hash: string;
  attach: string;
  num: integer;
 end;

 TPopList = class
  items: array[1..500] of Rpopitem;
  count: integer;
  constructor create;
  procedure clear;
  procedure addItemR(item:RPopitem);
  procedure addItem(subject,date,from,id,attach: string;num: integer);
  function getValue(id: integer;typ: string): string;
  procedure setHash(id: integer;hash: string);
 end;

var popitems: TPopList;

implementation

procedure TPopList.setHash;
begin
 if count < id then exit;
 items[id].hash := hash;
end;


function TPopList.getValue;
begin
 result := '';
 if count < id then exit;
 if typ = 'id' then result := items[id].id
 else if typ = 'date' then result := items[id].date
 else if typ = 'subject' then result := items[id].subject
 else if typ = 'from' then result := items[id].from
 else if typ = 'hash' then result := items[id].hash
 else if typ = 'attach' then result := items[id].attach;
end;

constructor TPopList.create;
begin
 count := 0;
 fillchar(items, sizeof(items), 0);
end;

procedure TPopList.clear;
begin
 count := 0;
 fillchar(items, sizeof(items), 0);
end;

procedure TPopList.addItem;
var
 rec: RpopItem;
begin
 rec.id := id;
 rec.subject := subject;
 rec.date := date;
 rec.from := from;
 rec.attach := attach;
 rec.num := num;
 addItemR(rec);
end;

procedure TPopList.addItemR;
begin
 count := count + 1;
 if (count > 500) then exit;
 items[count] := item;
end;

initialization

popitems := TPopList.create;

end.
